#include <bits/stdc++.h>

using namespace std;
#define int long long


void solve()
{
    int n;
    cin >> n;
    vector<int>a(n);
    for(int &x : a) cin >> x;
    vector<int>frep(n + 1);
    for(int x : a) frep[x]++;
    vector<int>len(n + 1);
    len[0] = frep[a[0]] == 1;
    for(int i = 1;i < n;i ++)
        if(frep[a[i]] == 1)
            len[i] = len[i - 1] + 1;
    int mx = *max_element(len.begin() , len.end());
    if(mx == 0)
    {
        cout << 0 << endl;
        return;
    }
    for(int i = 0;i < n;i ++)
    {
        if(len[i] == mx)
        {
            cout << (i - len[i]) + 2 << " " << i + 1 << endl;
            return;
        }
    }
    
}
signed main()
{
    int t; cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}